<include file='Common:header' />
<!-- /section:basics/navbar.layout -->
<div class="main-container" id="main-container">
	<!-- #section:basics/sidebar -->
	<include file='Common:left' />
	<!-- /section:basics/sidebar -->
	<div class="main-content">
		<div class="main-content-inner">
			<div class="page-content">
				<link rel="stylesheet" type="text/css" media="all" href="__PUBLIC__/sldate/daterangepicker-bs3.css" />
				<script type="text/javascript" src="__PUBLIC__/sldate/moment.js"></script>
				<script type="text/javascript" src="__PUBLIC__/sldate/daterangepicker.js"></script>
				<script type="text/javascript">
					$(document).ready(function() {
						$('#reservation').daterangepicker(null, function(start, end, label) {
							console.log(start.toISOString(), end.toISOString(), label);
						});
					});
				</script>
				<form name="admin_list_sea" class="form-search form-horizontal" method="post" action="{:U('news_list')}">
					<div class="row maintop">
						<div class="col-xs-12 col-sm-4">
							<select name="keytype">
								<option value="news_title" <if condition="($keytype eq 'news_title') or ($keytype eq '')">selected</if>>按标题</option>
								<option value="news_auto" <if condition="$keytype eq 'news_auto'">selected</if>>按发布人ID</option>
								<option value="news_author" <if condition="$keytype eq 'news_author'">selected</if>>按发布人名</option>
							</select>
							<select name="diyflag">
								<option value="">按属性</option>
								<foreach name="diyflag" item="v">
									<option value="{$v.diyflag_value}" <if condition="$diyflag_check eq $v['diyflag_value']">selected</if>>{$v.diyflag_name}({$v.diyflag_value})</option>
								</foreach>
							</select>
							<select name="opentype_check">
								<option value="">状态</option>
								<option value="1" <if condition="$opentype_check eq '1'">selected="selected"</if>>已审</option>
								<option value="0" <if condition="$opentype_check eq '0'">selected="selected"</if> >未审</option>
							</select>
						</div>

						<div class="col-xs-12 col-sm-3 hidden-xs btn-sespan">
							<div class="input-group">
										<span class="input-group-addon">
											<i class="glyphicon glyphicon-calendar fa fa-calendar"></i>
										</span>
								<input type="text"  name="reservation" id="reservation" class="sl-date" value="{$sldate}" placeholder="点击选择日期范围"/>
							</div>
						</div>


						<div class="col-xs-12 col-sm-3 btn-sespan">
							<div class="input-group">
									<span class="input-group-addon">
										<i class="ace-icon fa fa-check"></i>
									</span>
								<input type="text" name="key" id="key" class="form-control search-query admin_sea" value="{$keyy}" placeholder="输入需查询的关键字" />
									<span class="input-group-btn">
										<button type="submit" class="btn btn-xs btm-input btn-purple">
											<span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
											搜索
										</button>
									</span>
							</div>
						</div>

						<div class="input-group-btn">
							<a href="{:U('news_list')}">
								<button type="button" class="btn btn-xs all-btn btn-purple">
									<span class="ace-icon fa fa-globe icon-on-right bigger-110"></span>
									显示全部
								</button>
							</a>
						</div>


					</div>
				</form>



				<div class="row">
					<div class="col-xs-12">
						<div>
							<form id="alldel" name="alldel" method="post" action="{:U('news_alldel')}" >
								<input name="p" id="p" value="{:I('p',1)}" type="hidden" />
								<div class="table-responsive">
									<table class="table table-striped table-bordered table-hover" id="dynamic-table">
										<thead>
										<tr>
											<th class="hidden-xs center">
												<label class="pos-rel">
													<input type="checkbox" class="ace"  id='chkAll' onclick='CheckAll(this.form)' value="全选"/>
													<span class="lbl"></span>															</label>											</th>
											<th class="hidden-xs">ID</th>
											<th>文章标题</th>
											<th class="hidden-sm hidden-xs">所属栏目</th>
											<th class="hidden-sm hidden-xs">文章属性</th>
											<th class="hidden-xs">点击</th>
											<th class="hidden-xs">审核</th>
											<th class="hidden-xs">发布时间</th>
											<th style="border-right:#CCC solid 1px;">操作</th>
										</tr>
										</thead>

										<tbody>

										<foreach name="news" item="v">
											<tr>
												<td class="hidden-xs" align="center">
													<label class="pos-rel">
														<input name='n_id[]' id="navid" class="ace"  type='checkbox' value='{$v.n_id}'>
														<span class="lbl"></span>
													</label>
												</td>
												<td class="hidden-xs" align="center">{$v.n_id}</td>
												<td><a href="" target="_blank" title="{$v.news_title}">{$v.news_title|subtext=25}</a>【{$v['admin_realname']|default=$v['admin_username']}】</td>
												<td class="hidden-sm hidden-xs">{$v.menu_name}</td>
												<td class="hidden-sm hidden-xs">
													<if condition="strstr($v['news_flag'],'h') eq true"><span style="color:#03C">头</span></if>
													<if condition="strstr($v['news_flag'],'c') eq true"><span style="color:#060">荐</span></if>
													<if condition="strstr($v['news_flag'],'f') eq true"><span style="color:#09F">幻</span></if>
													<if condition="strstr($v['news_flag'],'a') eq true"><span style="color:#63C">特</span></if>
													<if condition="strstr($v['news_flag'],'s') eq true"><span style="color:#C0C">滚</span></if>
													<if condition="strstr($v['news_flag'],'p') eq true"><span style="color:#960">图</span></if>
													<if condition="strstr($v['news_flag'],'j') eq true"><span style="color:#C00">跳</span></if>
													<if condition="strstr($v['news_flag'],'d') eq true"><span style="color:#630">原</span></if>
													<if condition="strstr($v['news_flag'],'cp') eq true"><span style="color:#438eb9">产</span></if>
												</td>
												<td class="hidden-xs">{$v.news_hits}</td>
												<td class="hidden-xs">
													<if condition="$v['news_open'] eq 1">
														<a class="red" href="javascript:;" onclick="return stateyes({$v.n_id});" title="已审">
															<div id="zt{$v.n_id}"><button class="btn btn-minier btn-yellow">已审</button></div>
														</a>
														<else/>
														<a class="red" href="javascript:;" onclick="return stateyes({$v.n_id});" title="未审">
															<div id="zt{$v.n_id}"><button class="btn btn-minier btn-danger">未审</button></div>
														</a>
													</if>
												</td>
												<td class="hidden-xs">{$v.news_time|date='Y-m-d',###}</td>
												<td>
													<div class="hidden-sm hidden-xs action-buttons">
														<a class="green" href="{:U('news_edit',array('n_id'=>$v['n_id']))}" title="修改">
															<i class="ace-icon fa fa-pencil bigger-130"></i>
														</a>
														<a class="red del" href="{:U('news_del',array('n_id'=>$v['n_id'],'p'=>I('p',1)))}" title="回收站">
															<i class="ace-icon fa fa-trash-o bigger-130"></i>
														</a>
													</div>
													<div class="hidden-md hidden-lg">
															<div class="inline position-relative">
																<button class="btn btn-minier btn-primary dropdown-toggle" data-toggle="dropdown" data-position="auto">
																	<i class="ace-icon fa fa-cog icon-only bigger-110"></i>
																</button>
																<ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
																	<li>
																		<a href="{:U('news_edit',array('n_id'=>$v['n_id']))}" class="tooltip-success" data-rel="tooltip" title="" data-original-title="修改">
																			<span class="green">
																				<i class="ace-icon fa fa-pencil-square-o bigger-120"></i>
																			</span>
																		</a>
																	</li>

																	<li>
																		<a href="{:U('news_del',array('n_id'=>$v['n_id'],'p'=>I('p',1)))}"  class="tooltip-error del" data-rel="tooltip" title="" data-original-title="删除">
																			<span class="red">
																				<i class="ace-icon fa fa-trash-o bigger-120"></i>
																			</span>
																		</a>
																	</li>
																</ul>
															</div>
													</div>
												</td>
											</tr>
										</foreach>
										<tr>
											<td align="left"><button id="btnsubmit" class="btn btn-white btn-yellow btn-sm">删</button> </td>
											<td colspan="8" align="right" class="hidden-xs">{$page}</td>
											<td colspan="8" align="right" class="hidden-lg hidden-md hidden-sm">{$page_min}</td>
										</tr>
										</tbody>
									</table>
								</div>
							</form>
						</div>
					</div>
				</div>

				<include file='Common:header_nav' />

			</div><!-- /.page-content -->
		</div>
	</div><!-- /.main-content -->

	<script>
		$(function(){
			//删除操作
			var $del = $(".del");
			$del.click(function(){
				var $url=this.href;
				layer.confirm('你确定要删除吗？', {icon: 3}, function(index){
				layer.close(index);
				$.get($url, function(data){
					if(data.status){
						layer.alert(data.info, {icon: 6}, function(index){
							layer.close(index);
							window.location.href=data.url;
						});
					} else {
						layer.alert(data.info, {icon: 5}, function(index){
							layer.close(index);
							//window.location.href="{:U('we_menu_list')}";
						});
					}
				}, "json");
				});
				return false;
			});
		});


		function unselectall(){
			if(document.myform.chkAll.checked){
				document.myform.chkAll.checked = document.myform.chkAll.checked&0;
			}
		}
		function CheckAll(form){
			for (var i=0;i<form.elements.length;i++){
				var e = form.elements[i];
				if (e.Name != 'chkAll'&&e.disabled==false)
					e.checked = form.chkAll.checked;
			}
		}

	</script>
	<script>
		$(function(){
			$('#alldel').ajaxForm({
				beforeSubmit: checkForm, // 此方法主要是提交前执行的方法，根据需要设置，一般是判断为空获取其他规则
				success: complete, // 这是提交后的方法
				dataType: 'json'
			});

			function checkForm(){
				var chk_value =[];
				$('input[id="navid"]:checked').each(function(){
					chk_value.push($(this).val());
				});

				if(!chk_value.length){
					layer.alert('至少选择一个删除项', {icon: 5});
					return false;
				}
			}

			function complete(data){
				if(data.status==1){
					layer.alert(data.info, {icon: 6}, function(index){
						layer.close(index);
						window.location.href=data.url;
					});
				}else{
					layer.alert(data.info, {icon: 5}, function(index){
						layer.close(index);
						//window.location.href="{:U('news_list')}";
					});
				}
			}

		});


		function stateyes(val){
			$.post('{:U("news_state")}',
					{x:val},
					function(data){
						var $v=val;
						if(data.status){
							if(data.info=='未审'){
								var a='<button class="btn btn-minier btn-danger">未审</button>'
								$('#zt'+val).html(a);
								return false;
							}else{
								var b='<button class="btn btn-minier btn-yellow">已审</button>'
								$('#zt'+val).html(b);
								return false;
							}

						}else{
							layer.alert(data.info, {icon: 5});
						}
					});
			return false;
		}
	</script>
	<include file='Common:footer' />

</div><!-- /.main-container -->
</body>
</html>
